﻿using HR.Config;
using HR.Filters;
using HR.IService;
using HR.Models;
using Microsoft.AspNetCore.Mvc;

namespace HR.Controllers
{
    public class HumanFileDeleController : Controller
    {
        private readonly IHumanFileDeleService ihfd;

        public HumanFileDeleController(IHumanFileDeleService ihfd)
        {
            this.ihfd = ihfd;
        }
        [TypeFilter(typeof(RoleFilterAttribute))]
        /// <summary>
        /// 人力资源档案删除视图
        /// </summary>
        /// <returns></returns>
        public IActionResult Index()
        {
            return View();
        }

        /// <summary>
        /// 查询表单，带where条件
        /// </summary>
        /// <param name="hs"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> HumanFileFind([FromForm] HFSelect hs)
        {
            Paging<human_file> pg = await ihfd.HumanFileFind(hs);
            return Json(pg);
        }
        /// <summary>
        /// 根据档案ID进行档案的“删除操作”，实际是修改human_file_status字段为false
        /// </summary>
        /// <param name="human_id"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<IActionResult> HumanFileUdpDel(short huf_id)
        {
            int res = await ihfd.HumanFileUdpDel(huf_id);
            return Json(res);
        }
        [TypeFilter(typeof(RoleFilterAttribute))]
        /// <summary>
        /// 人力资源档案恢复视图
        /// </summary>
        /// <returns></returns>
        public IActionResult IndexResume()
        {
            return View();
        }
        /// <summary>
        /// 根据档案ID进行档案的“恢复操作”，实际是修改human_file_status字段为false
        /// </summary>
        /// <param name="human_id"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<IActionResult> HumanFileUdpRes(short huf_id)
        {
            int res = await ihfd.HumanFileUdpRes(huf_id);
            return Json(res);
        }
        [TypeFilter(typeof(RoleFilterAttribute))]
        /// <summary>
        /// 人力资源档案永久删除视图
        /// </summary>
        /// <returns></returns>
        public IActionResult IndexDelete()
        {
            return View();
        }
        /// <summary>
        /// 查询所有伪删除的档案数据
        /// </summary>
        /// <returns></returns>
        public async Task<IActionResult> HumanFileUdpDelFinds(int pagesize,int pagecurrent)
        {
            Paging<human_file> pg = await ihfd.HumanFileUdpDelFinds(pagesize, pagecurrent);
            return Json(pg);
        }
        /// <summary>
        /// 永久删除单条档案信息
        /// </summary>
        /// <param name="huf_id"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<IActionResult> HumanFileDelete(short huf_id)
        {
            int res = await ihfd.HumanFileDelete(huf_id);
            return Json(res);
        }
    }
}
